﻿<%@ Page Title="Cungmuanao.com - Quản Lý Chi Nhánh" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="ManageBranchs.aspx.cs" Inherits="Admin_ManageBranchs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="LeftContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <div class="title">Quản Lý Chi Nhánh AnLoan</div>
    
    <div class="body">
<ul style="list-style-type: square">
        <li>
            <asp:HyperLink ID="hplManageAnLoan" runat="server" NavigateUrl="~/Admin/ManageWebAnLoan.aspx">Quản Lý Website AnLoan</asp:HyperLink>
        </li>
</ul>
<hr />
<asp:GridView runat="server" ID="gvwBranchs" Width="100%" 
        AutoGenerateColumns="False" DataSourceID="objAllBranchs" DataKeyNames="ID"
        AllowPaging="True" PageSize="50" EmptyDataText="<b>Chưa có Chi Nhánh nào</b>"
        BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" 
        CellPadding="4" onrowcreated="gvwBranchs_RowCreated" 
        onrowdeleted="gvwBranchs_RowDeleted" 
        onselectedindexchanged="gvwBranchs_SelectedIndexChanged">
        <PagerSettings FirstPageText="Về đầu" LastPageText="Về cuối"  />
        <RowStyle ForeColor="#330099" BackColor="White" />
    <Columns>
         <asp:TemplateField HeaderText="No.">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblSTT" Text='<%#Container.DataItemIndex + 1 %>' />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Tên Chi Nhánh">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblName" Text='<%#Eval("Name")  %>'  />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Đường">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblAddress" Text='<%#(string)Eval("Number") +"  Đường "+ (string)Eval("Address") +"  P."+ (string)Eval("Ward")+"  Q."+ (string)Eval("District") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        
        <%--<asp:TemplateField HeaderText="Phường">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblWard" Text='<%#Eval("Ward") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Quận">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblDistrict" Text='<%#Eval("District") %>' />
            </ItemTemplate>
        </asp:TemplateField>--%>
        
        <asp:TemplateField HeaderText="Thành Phố">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblCity" Text='<%#Eval("City") %>' />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Phone">
            <ItemTemplate>
                <asp:Literal runat="server" ID="lblPhone" Text='<%#Eval("Phone") %>'  />
            </ItemTemplate>
        </asp:TemplateField>
        
        <asp:CheckBoxField ItemStyle-HorizontalAlign="Center" HeaderText="HeadOffice" DataField="IsHeadOffice" ReadOnly="true" />
        
        <asp:CommandField HeaderText="Edit" ButtonType="Image" SelectImageUrl="~/Images/edit.gif"
                SelectText="Edit" ShowSelectButton="True">
                <ItemStyle HorizontalAlign="Center"  />
        </asp:CommandField>
        
        <asp:CommandField HeaderText="Delete" ButtonType="Image" DeleteImageUrl="~/Images/delete.gif"
                DeleteText="Delete" ShowDeleteButton="True">
                <ItemStyle HorizontalAlign="Center"  />
            </asp:CommandField>
    </Columns>
         <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
         <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
         <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
         <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
         <AlternatingRowStyle BackColor="#DCDCDC" />
 </asp:GridView>
 <asp:ObjectDataSource runat="server" ID="objAllBranchs" TypeName="BLL.BranchAnLoan.Branchs" DeleteMethod="DeleteBranch" SelectMethod="ListBranch">
 </asp:ObjectDataSource>
 
 
 <hr />
<p></p>

<asp:DetailsView runat="server" ID="dvwCurrBracnh" DefaultMode="Insert" 
        AutoGenerateRows="False" DataKeyNames="ID" Width="70%"
    HeaderText="<b>Chi tiết Chi Nhánh</b>" BackColor="White" 
        AutoGenerateInsertButton="true" AutoGenerateEditButton="true" AutoGenerateDeleteButton="false" 
    DataSourceID="objCurrBranch" BorderColor="#CC9966" BorderStyle="None" 
        BorderWidth="1px" CellPadding="4" onitemcommand="dvwCurrBracnh_ItemCommand" 
        oniteminserted="dvwCurrBracnh_ItemInserted" 
        onitemupdated="dvwCurrBracnh_ItemUpdated">
    <FieldHeaderStyle Width="100px" />
    <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
    <RowStyle ForeColor="#330099" BackColor="White" />
    <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
    <Fields>
        <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="true" InsertVisible="false"
                Visible="false" SortExpression="ID" />
        <asp:TemplateField HeaderText="Tên">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtName" Text='<%#Bind("Name") %>' Width="100%" />
                <asp:RequiredFieldValidator ID="valRequireName" runat="server" ControlToValidate="txtName" SetFocusOnError="true"
                  Text="Tên không được bỏ trống" ToolTip="Tên không được bỏ trống" Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Số">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtNumber" Text='<%#Bind("Number") %>' />
                <asp:RequiredFieldValidator ID="valRequireNumber" runat="server" ControlToValidate="txtNumber" SetFocusOnError="true"
                  Text="Số không được bỏ trống" ToolTip="Số không được bỏ trống" Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Đường">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtAddress" Text='<%#Bind("Address") %>' Width="100%" />
                <asp:RequiredFieldValidator ID="valRequireAddress" runat="server" ControlToValidate="txtAddress" SetFocusOnError="true"
                  Text="Địa Chỉ không được bỏ trống" ToolTip="Địa Chỉ không được bỏ trống" Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Phường">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtWard" Text='<%#Bind("Ward") %>'  />
                <asp:RequiredFieldValidator ID="valRequireWard" runat="server" ControlToValidate="txtWard" SetFocusOnError="true"
                  Text="Phường không được bỏ trống" ToolTip="Phường không được bỏ trống" Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Quận">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtDistrict" Text='<%#Bind("District") %>'  />
                <asp:RequiredFieldValidator ID="valRequireDistrict" runat="server" ControlToValidate="txtDistrict" SetFocusOnError="true"
                  Text="Quận không được bỏ trống" ToolTip="Quận không được bỏ trống" Display="Dynamic"></asp:RequiredFieldValidator>

            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Thành Phố">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtCity" Text='<%#Bind("City") %>'  />
                <asp:RequiredFieldValidator ID="valRequireCity" runat="server" ControlToValidate="txtCity" SetFocusOnError="true"
                  Text="Thành Phố không được bỏ trống" ToolTip="Thành Phố không được bỏ trống" Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="Phone">
            <EditItemTemplate>
                <asp:TextBox runat="server" ID="txtPhone" Text='<%#Bind("Phone") %>' Width="100%"  />
                 <asp:RequiredFieldValidator ID="valRequirePhone" runat="server" ControlToValidate="txtPhone" SetFocusOnError="true"
                  Text="Phone không được bỏ trống" ToolTip="Phone không được bỏ trống" Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
        </asp:TemplateField>
        
        <asp:TemplateField HeaderText="HeadOffice">
            <EditItemTemplate>
                <asp:CheckBox runat="server" ID="cbHeadOffice" Checked='<%#Bind("IsHeadOffice") %>' />
            </EditItemTemplate>
        </asp:TemplateField>
        
    </Fields>
    <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
    <EditRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
    </asp:DetailsView>
    
    <asp:ObjectDataSource runat="server" ID="objCurrBranch" TypeName="BLL.BranchAnLoan.Branchs" SelectMethod="GetBranch" 
    InsertMethod="InsertBranch" UpdateMethod="UpdateBranch">
        <SelectParameters>
            <asp:ControlParameter PropertyName="SelectedValue" ControlID="gvwBranchs" Type="Int32" Name="branchID" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="ward" Type="String" />
            <asp:Parameter Name="district" Type="String" />
            <asp:Parameter Name="city" Type="String" />
            <asp:Parameter Name="phone" Type="String" />
            <asp:Parameter Name="isHeadOffice" Type="Boolean" />
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="number" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="id" Type="Int32" />
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="ward" Type="String" />
            <asp:Parameter Name="district" Type="String" />
            <asp:Parameter Name="city" Type="String" />
            <asp:Parameter Name="phone" Type="String" />
            <asp:Parameter Name="isHeadOffice" Type="Boolean" />
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="number" Type="String" />
        </UpdateParameters>
    </asp:ObjectDataSource>
    </div>
    <div class="bottom"></div>
</asp:Content>

